package top.kaoshanji.p1ch06a;

/**
 * 代码清单-p1ch06a-110页c：将this传递给另一个方法
 * author kaoshanji
 * ^_^
 * create time 2025/3/8 16:01
 */
public class PassingThis {

    public static void main(String[] args) {
        new Person().eat(new Apple());
    }

}

class Person {
    public void eat(Apple apple) {
        Apple peeled = apple.getPeeled();
        System.out.println("Yummy");
    }
}

class Peeler {
    static Apple peel(Apple apple) {
        // ... remove peel
        return apple; // Peeled
    }
}

class Apple {
    Apple getPeeled() {
        return Peeler.peel(this);
    }
}

